Page({
  data: {
    words: [],
  },

  onLoad() {
    console.log(getApp().globalData.favorites);
    this.setData({
      words:this.removeDuplicates(getApp().globalData.favorites),
    })
  },
  removeDuplicates: function(words) {
    const seen = new Set();
    return words.filter(word => {
        const duplicate = seen.has(word.wordId);
        seen.add(word.wordId);
        return !duplicate;
    });
  },
  goTo: function(e) {
    getApp().globalData.currentWord = this.data.words[e.currentTarget.dataset.index];
    wx.navigateTo({url: '/pages/detail/detail'});
  },
});